from django.test import TestCase

# Create your tests here.

# from captcha.image import ImageCaptcha
# import matplotlib.pyplot as plt
# import numpy as np
# import random
# import string
#
# characters = string.digits + string.ascii_lowercase
# print(characters)
#
# width, height, n_len, n_class = 170, 80, 4, len(characters)
#
# generator = ImageCaptcha(width=width, height=height)
# random_str = ''.join([random.choice(characters) for j in range(4)])
# img = generator.create_captcha_image(random_str, (0, 0, 153), (255, 255, 255))
# img.save("generate.png")
# img.show()
# plt.imshow(img)
# plt.title(random_str)


from captcha.image import ImageCaptcha
import matplotlib.pyplot as plt
import numpy as np
import random
import string
from PIL import Image

characters = string.digits + string.ascii_uppercase

width, height, n_len, n_class = 170, 80, 4, len(characters)

generator = ImageCaptcha(width=width, height=height)
random_str = ''.join([random.choice(characters) for j in range(4)])
img = generator.generate_image(random_str)
print(random_str)
print(img)

# # 将图片保存在目录yzm文件夹下
# # file_name='./yzm/'+random_str+'_'+str(i)+'.jpg'
# # img.save(file_name)
# img.show()
# plt.imshow(img)
# plt.title(random_str)
